#ifndef _TEST_FUNCTION_INITIALIZER_H_
#define _TEST_FUNCTION_INITIALIZER_H_

#include "TestFunction.h"

#include <vector>
#include <map>
#include <string>


std::map<std::string, TestFunction*>* getRegTestFunsMap();


class TestFunctionInitializer
{
    public:
        template <typename C>
        TestFunctionInitializer(std::string className, std::string funName, int(C::*testFun)()) 
        {
            std::string fullName(className + "::" + funName);
            std::map<std::string, TestFunction*> &regTestFuns = _getRegTestFuns();
            regTestFuns[fullName] = new TestFunctionT<C>(testFun);
        }
        static TestFunction* getTestFun(std::string funName);
        static void getAllTestFunsInClass(std::string className, std::vector<std::string> *funNames);
    private:
        static std::map<std::string, TestFunction*>& _getRegTestFuns();
};


#define REG_TEST_FUN(className, funName) \
    static TestFunctionInitializer g_##className##_##funName##_initializer(#className, #funName, &className::funName)

#endif


